package ch02.demo;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

public class demo2 {
    public static void main(String[] args) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse("src/ch02/demo/demo.xml");
            NodeList list = doc.getElementsByTagName("pubDate");
            Element pubDateElement = (Element) list.item(0);
            String pubDate=pubDateElement.getFirstChild().getNodeValue();
            System.out.println(pubDate);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
